package pack02_wordcount_partitioner;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @author lilulu
 * @date 2023/2/11 0:46
 * 主要分散开在不同的reducer上面
 */
public class WordCountPartitioner extends Partitioner<Text, LongWritable> {
    @Override
    public int getPartition(Text text, LongWritable longWritable, int i) {

        String k2 = text.toString();
        int num = Math.abs(k2.hashCode()) % i;
        return num;
    }
}
